package Meta

import (
	"db2s/global"
)

func (ma Meta) viewEr(drive string) (ter ViewEr, err error) {
	if ter, err = NewMetaView(drive,ma.Parameter); err != nil {
		return
	}
	return
}
func (ma Meta) mViewEr(drive string) (ter ViewEr, err error) {
	if ter, err = NewMetaMView(drive,ma.Parameter); err != nil {
		return
	}
	return
}
func (ma Meta) viewName() (meta any, err error) {
	var ter ViewEr
	var res []any
	for k, v := range ma.Drive {
		if ter, err = ma.viewEr(v); err != nil {
			return
		}
		var result global.Return
		if result, err = ter.Name(ma.Parameter.Con[k]); err != nil {
			return
		}
		res = append(res, result.Result)
	}
	meta = joinResult(ma.Join, res)
	return
}
func (ma Meta) mViewName() (meta any, err error) {
	var ter ViewEr
	var res []any
	for k, v := range ma.Drive {
		if ter, err = ma.mViewEr(v); err != nil {
			return
		}
		var result global.Return
		if result, err = ter.Name(ma.Parameter.Con[k]); err != nil {
			return
		}
		res = append(res, result.Result)
	}
	meta = joinResult(ma.Join, res)
	return
}
func (ma Meta) viewExistence() (meta any, err error) {
	var ter ViewEr
	var res []any
	for k, v := range ma.Drive {
		if ter, err = ma.viewEr(v); err != nil {
			return
		}
		var result global.Return
		if result, err = ter.Existence(ma.Parameter.Con[k]); err != nil {
			return
		}
		res = append(res, result.Result)
	}
	meta = joinResult(ma.Join, res)
	return
}
func (ma Meta) mViewExistence() (meta any, err error) {
	var ter ViewEr
	var res []any
	for k, v := range ma.Drive {
		if ter, err = ma.mViewEr(v); err != nil {
			return
		}
		var result global.Return
		if result, err = ter.Existence(ma.Parameter.Con[k]); err != nil {
			return
		}
		res = append(res, result.Result)
	}
	meta = joinResult(ma.Join, res)
	return
}

func (ma Meta) viewDrop() (meta any, err error) {
	var ter ViewEr
	var res []any
	for k, v := range ma.Drive {
		if ter, err = ma.viewEr(v); err != nil {
			return
		}
		var result global.Return
		if result, err = ter.ViewDrop(ma.Parameter.Con[k]); err != nil {
			return
		}
		res = append(res, result)
	}
	meta = joinResult(ma.Join, res)
	return
}
func (ma Meta) mViewDrop() (meta any, err error) {
	var ter ViewEr
	var res []any
	for k, v := range ma.Drive {
		if ter, err = ma.mViewEr(v); err != nil {
			return
		}
		var result global.Return
		if result, err = ter.ViewDrop(ma.Parameter.Con[k]); err != nil {
			return
		}
		res = append(res, result)
	}
	meta = joinResult(ma.Join, res)
	return
}